<?php
include("include/config.inc.php");
$msg="";
if(isset($_REQUEST['userIns']))
{
	$useName=$_POST['userName'];
	$usePass=$_POST['userpassword'];
	$useComPass=$_POST['userpasswordCom'];
	if($usePass == $useComPass)
	{
	  $insUserQuery="INSERT INTO  `user` (`userName` ,`password` ,`userType`)
	               VALUES ( '".$useName."',  '".md5($usePass)."', 'User')";
	  $insUserQueryRes=mysql_query($insUserQuery);
  }
  else
  {
  	$msg = "Password are not match..";
  }
}

$userArr = array();
$i=0;
$selUser="SELECT userId,userName,password,userType
            FROM user";
$selUserRes=mysql_query($selUser);
while($selUserResRow=mysql_fetch_array($selUserRes))
{
	$userArr[$i]['userId']   = $selUserResRow['userId'];
	$userArr[$i]['userName'] = $selUserResRow['userName'];
	$userArr[$i]['password'] = $selUserResRow['password'];
	$userArr[$i]['userType'] = $selUserResRow['userType'];
	$i++;
}
if(isset($_GET['userId']))
{
  	if($_GET['userId'] != "")
  	{
  		$delUserQue="DELETE FROM user 
  		              WHERE userId=".$_GET['userId'];
  		$delUserQueRes=mysql_query($delUserQue);
  		$delUsermenu="DELETE FROM usermenu
  		               WHERE userId=".$_GET['userId'];
      $delUsermenu=mysql_query($delUsermenu);
  	}
	header("location:list.php");
}
include("./bottom.php");
$smarty->assign("msg",$msg);
$smarty->assign("userArr",$userArr);
$smarty->display('list.tpl');
?>